package com.cy.springcloudalibaba.controllers;

import com.cy.springcloudalibaba.services.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 订单
 * @ClassName: OrderController
 * @Author: chenyu
 * @Date: 2025/2/6 10:17
 */
@Slf4j
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/order")
    public Integer createOrder(@RequestParam("userId") Integer userId,
                               @RequestParam("productId") Integer productId) throws Exception {
        log.info("[createOrder] 请求下单，用户：{}，商品：{}", userId, productId);

        return orderService.createOrder(userId, productId);
    }
}
